package com.leyu.mall.service.cms.impl;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.leyu.mall.common.facade.ICmsChannelFacade;
import com.leyu.mall.dao.cms.CmsChannelMapper;
import com.leyu.mall.domain.cms.CmsChannel;
import com.leyu.mall.service.cms.ICmsChannelService;

@Service
@Transactional(rollbackFor=Exception.class)
public class CmsChannelServiceImpl implements ICmsChannelService,ICmsChannelFacade{
	
	@Resource(name="cmsChannelMapper")
	private CmsChannelMapper cmsChannelMapper;
	

	public CmsChannel find(Long entity_id)  throws Exception{
		return cmsChannelMapper.getCmsChannelById(entity_id);
	}

	public void save(CmsChannel entity) throws Exception{
		if(entity.getChannelId()== null){
			cmsChannelMapper.addCmsChannel(entity);
			System.out.println("entity.getChannelId()== null++++++"+entity.getChannelId());
		}
		else{
		
			cmsChannelMapper.editCmsChannel(entity);
		}
		
//		cmsChannelMapper.addCmsChannel(entity);
	}
	public void delete(Long  id)throws Exception{
		cmsChannelMapper.removeCmsChannel(id);
	}
	public List<CmsChannel> getcmsChannelList()throws Exception{
		System.out.print("----CmsChannelServiceImpl.getcmsChannelList()-------------");
//		return new ArrayList();
		return cmsChannelMapper.getAllCmsChannel();
		
	}
	public List<CmsChannel> getDisplayChannelList()throws Exception{
		 
		return cmsChannelMapper.getDisplayChannelList();
		
	}
	
}